import $ from "jquery";
import { Modal } from "bootstrap";
import "./dialog-template.scss";

const hbsTemplate = require("./dialog-template.hbs");

export class MessageBox {
  public static ShowNitification(title: string, message: string) {
    const htmlString = hbsTemplate({
      title,
      message,
    });
    const element = $(htmlString);
    $("body").append(element);
    const dialog = element.get(0);
    if (dialog instanceof HTMLDivElement) {
      dialog.addEventListener("hidden.bs.modal", () => {
        element.remove();
      });
      const modal = new Modal(dialog);
      modal.show();
    }
  }
}
